package com.binge.thread;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.concurrent.CompletableFuture;

/**
 * ClassName:ThreadNote
 * Package:com.binge.thread
 * Description:
 *
 * @Author @Bin
 * @Date 2024/10/9-14:07
 * @Version: v1.0
 */
@Slf4j
public class ThreadNote {
    @Test
    public void testCompletableFuture() {
        long number = (long) (Math.random() * Math.pow(10, 10));
        log.info("number:{}", number);

        CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> {
            log.info("supplyAsync");
            return number;
        }).thenApplyAsync((r) -> {
            log.info("thenApplyAsync");
            return r + 1;
        }).thenAcceptAsync((r) -> {
            log.info("thenAcceptAsync");
            log.info("result:{}", r);
        });
    }
}
